package com.test.jogl;

import javax.media.opengl.GL;

public class Shape {

   public static final double RAYON_NEUTRE = 1.0;
   public static final double HEX_INTERN_RADIUS = (0.5 / Math.tan(Math.toRadians(30.0))) * RAYON_NEUTRE;
   
   public static void hexagon(GL gl, float initX, float initY, float edge) {

      float x1, y1;
      float x2, y2;
      float x3, y3;
      float x4, y4;
      float x5, y5;
      float x6, y6;
      float z = 0.0f;
      gl.glShadeModel(GL.GL_FLAT);
      gl.glNormal3f(0.0f, 0.0f, 1.0f);

      gl.glBegin(GL.GL_POLYGON);
      x1 = initX - edge * 0.5F;
      y1 = initY - (float)HEX_INTERN_RADIUS * edge;
      gl.glVertex3f(x1, y1, z);
      System.out.println("x1: " + x1 + "\ty1: " + y1);

      x2 = x1 + edge;
      y2 = y1;
      gl.glVertex3f(x2, y2, z);
      System.out.println("x2: " + x2 + "\ty2: " + y2);

      x3 = x2 + 0.5F * edge;
      y3 = y2 + (float)HEX_INTERN_RADIUS * edge;
      gl.glVertex3f(x3, y3, z);
      System.out.println("x3: " + x3 + "\ty3: " + y3);

      x4 = x2;
      y4 = y3 + (float)HEX_INTERN_RADIUS * edge;
      gl.glVertex3f(x4, y4, z);
      System.out.println("x4: " + x4 + "\ty4: " + y4);

      x5 = x1;
      y5 = y4;
      gl.glVertex3f(x5, y5, z);
      System.out.println("x5: " + x5 + "\ty5: " + y5);

      x6 = x1 - (x3 - x2);
      y6 = y3;
      gl.glVertex3f(x6, y6, z);
      System.out.println("x6: " + x6 + "\ty6: " + y6 + "\n");
      gl.glEnd();
   }
}
